package cn.limc.ohoscharts.demo.slice;

import cn.limc.ohoscharts.demo.common.BaseAbility;
import cn.limc.ohoscharts.demo.ResourceTable;
import cn.limc.ohoscharts.axis.Axis;
import cn.limc.ohoscharts.entity.IChartData;
import cn.limc.ohoscharts.entity.IStickEntity;
import cn.limc.ohoscharts.entity.ListChartData;
import cn.limc.ohoscharts.event.IZoomable;
import cn.limc.ohoscharts.view.SlipStickChart;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;

public class SlipStickChartAbility extends BaseAbility {

  SlipStickChart slipstickchart;

  @Override
  protected void onStart(Intent intent) {
    super.onStart(intent);
    setUIContent(ResourceTable.Layout_ability_slip_stick_chart);

    initSlipStickChart();
  }


//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        // Inflate the menu; this adds items to the action bar if it is present.
//        getMenuInflater().inflate(R.menu.slip_stick_chart, menu);
//        return true;
//    }

  private void initSlipStickChart() {
    this.slipstickchart = (SlipStickChart) findComponentById(ResourceTable.Id_slipstickchart);

    slipstickchart.setAxisXColor(Color.LTGRAY.getValue());
    slipstickchart.setAxisYColor(Color.LTGRAY.getValue());
    slipstickchart.setLatitudeColor(Color.GRAY.getValue());
    slipstickchart.setLongitudeColor(Color.GRAY.getValue());
    slipstickchart.setBorderColor(Color.LTGRAY.getValue());
    slipstickchart.setLongitudeFontColor(Color.WHITE.getValue());
    slipstickchart.setLatitudeFontColor(Color.WHITE.getValue());
    slipstickchart.setDataQuadrantPaddingTop(6);
    slipstickchart.setDataQuadrantPaddingBottom(1);
    slipstickchart.setDataQuadrantPaddingLeft(1);
    slipstickchart.setDataQuadrantPaddingRight(1);
    // slipstickchart.setAxisYTitleQuadrantWidth(50);
    // slipstickchart.setAxisXTitleQuadrantHeight(20);
    slipstickchart.setAxisXPosition(Axis.AXIS_X_POSITION_BOTTOM);
    slipstickchart.setAxisYPosition(Axis.AXIS_Y_POSITION_RIGHT);

    // // 最大纬线数
    // slipstickchart.setLatitudeNum(2);
    // // 最大经线数
    // slipstickchart.setLongitudeNum(3);
    // 最大价格
    slipstickchart.setMaxValue(600000);
    // 最小价格
    slipstickchart.setMinValue(100);

    slipstickchart.setDisplayFrom(10);

    slipstickchart.setDisplayNumber(30);

    slipstickchart.setMinDisplayNumber(5);

    slipstickchart.setZoomBaseLine(IZoomable.ZOOM_BASE_LINE_CENTER);

    slipstickchart.setDisplayLongitudeTitle(true);
    slipstickchart.setDisplayLatitudeTitle(true);
    slipstickchart.setDisplayLatitude(true);
    slipstickchart.setDisplayLongitude(true);
    ShapeElement background = new ShapeElement();
    background.setRgbColor(new RgbColor(00, 00, 00));
    slipstickchart.setBackground(background);


    slipstickchart.setDataMultiple(100);
    slipstickchart.setAxisYDecimalFormat("#,##0.00");
    slipstickchart.setAxisXDateTargetFormat("yyyy/MM/dd");
    slipstickchart.setAxisXDateSourceFormat("yyyyMMdd");

    IChartData<IStickEntity> vol = new ListChartData<IStickEntity>(this.vol);
    // 为chart1增加均线
    slipstickchart.setStickData(vol);
  }


}
